import 'dart:html';
import 'dart:async';

num clicks = 0;
num click_upgrade = 1;
num upgrade_costs = 10;
num Upgrades = 0;
Timer timer = null;

void main() {
  querySelector("#b_click")
      ..text = "Click me !"
      ..onClick.listen(proclick);
  
  querySelector("#b_upgrade")
        ..text = "Upgrade !"
        ..onClick.listen(proupgrade);
  
  querySelector("#up_cost").text = upgrade_costs.toString();
  querySelector("#Upgrades").text = Upgrades.toString();
  
  timer = new Timer.periodic(new Duration(seconds: 2), proctimer);
}

void proclick(MouseEvent event) {
  clicks = clicks+click_upgrade;
  
  querySelector("#sample_text_id").text = clicks.toString();
}

void proupgrade(MouseEvent event) {
  if (clicks >= upgrade_costs) 
  {
    click_upgrade++;
    Upgrades++;
    upgrade_costs = click_upgrade * click_upgrade * 10;
  }
  
  querySelector("#up_cost").text = upgrade_costs.toString();
  querySelector("#Upgrades").text = Upgrades.toString();
}

void proctimer(Timer timer) {
  querySelector("#sample_text_id").text = (++clicks).toString();  
}